import apiAxios from "./ApiServer"
import mockAxios from "./MockServer"

//每一个函数对应着一个api
//getBaseCategoryList:三级分类对应的接口
//getBanners : 轮播图对应的接口
//getFloors : 楼层对应的接口
export const getBaseCategoryList = () => apiAxios.get("/product/getBaseCategoryList")
export const getBanners = () => mockAxios.get("/banners")
export const getFloors = () => mockAxios.get("/floors")


//search路由&detail路由对应的接口
//getGoods 获取所有的商品
//getGoodDetail 获取指定商品的详情
export const getGoods = options => apiAxios.post("/list",options)
export const getGoodDetail = skuid => apiAxios.get(`/item/${skuid}`)

//购物车相关的接口
export const addGoodsToCart = (skuId,skuNum) => apiAxios.post(`/cart/addToCart/${ skuId }/${ skuNum }`)
export const getGoodsFromCart = () => apiAxios.get(`/cart/cartList`)
export const updateCheckedForCartGood = (skuID,isChecked) => apiAxios.get(`/cart/checkCart/${skuID}/${isChecked}`)
export const delGoodsFromCart = (skuId) => apiAxios.delete(`/cart/deleteCart/${skuId}`)

//登录&注册
export const register = (phone,password,code,nickName) => apiAxios.post(`/user/passport/register`,{phone,password,code,nickName})
export const login = (phone,password) => apiAxios.post(`/user/passport/login`,{phone,password})
export const logout = () => apiAxios.get(`/user/passport/logout`)
export const autologin = () => apiAxios.get(`/user/passport/auth/getUserInfo`)

//订单请求
export const getTrade = () => apiAxios.get("/order/auth/trade")
export const getOrders = (page,limit) => apiAxios.get(`/order/auth/${page}/${limit}`)
export const getPayInfo = (orderId) => apiAxios.get(`/payment/weixin/createNative/${orderId}`)

export const submitOrder = (tradeNo,order) => apiAxios({
    url: '/order/auth/submitOrder',
    method:"post",
    params: {
        tradeNo
    },
    data:order
})
export const getPayStatus = (orderId) => apiAxios.get(`/payment/weixin/queryPayStatus/${orderId}`)

